﻿
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- https请求加 -->
<!-- <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" /> -->
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
    <title>登录</title>
    
<script src="http://apps.bdimg.com/libs/jquery/1.11.3/jquery.min.js"></script>
<!--json-->
        <script src="js/json2.js"></script>
        
        <SCRIPT type="text/javascript">
        /* function keyLogin(){
        	 if (event.keyCode==13)  //回车键的键值为13
        	   document.getElementByIdx_x("login").click(); //调用登录按钮的登录事件
        	} */
        
        
        function KeyDown() {
          if (event.keyCode == 13)
          {	
            Login(); 
          }
        }
        
        </SCRIPT>
<link rel="stylesheet" href="css/login.css" />
</head>
<body onkeydown="keyLogin();">
    <div class="box">
        <div class="weltit">WELCOME <span class="redtit">BACK</span></div>
        <span class="systemtitle">后台管理平台</span>
        <form name="Form1" onkeydown=KeyDown()>
            <input id="inputaccount" class="users" type="text"  />
            <input id="inputpass" class="users" type="password"  />
            <!-- <label><input type="checkbox" id="chkRememberPwd" /> <span>记住我</span></label> -->
            <input id="login" class="buttons" type="button" onclick="Login()" value="登 录"  />
        </form>
    </div>
    
</body>
<script>

	
    function Login() {
        var account = $("#inputaccount").val();
        var pass = $("#inputpass").val();
        if (account.length <= 0 || pass.lenght <= 0) {
            alert("账号密码不能为空");
            return;
        };
        $.ajax({
            type: "POST",
            url: 'PeopleAction_login.action',
            data:{
    		   username:$("#inputaccount").val(),
    		   password:$("#inputpass").val(),
    		}, 
            dataType:"json",
            async: false,
            success: function (data) {
                    console.log(data);
                    msg = eval("(" + data + ")");
                    if (msg.msg==1) {
                        location.href = "upload.html";
                    }
                    else if(msg.msg==0) {
                        alert("权限不足！！");
                    }
                    else {
                    	alert("用户名或密码不正确！！");
                    }
                },
                error: function (err) {
                    alert("出现异常！！");
                    msg = eval("(" + err + ")");
                }
            });
     };
    
    
</script>

</html>

